
<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module simpleparse.parser</title>
</head><body bgcolor="#f0f0f8">

<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="simpleparse.html"><font color="#ffffff">simpleparse</font></a>.parser</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/mcfletch/pylive/simpleparse/parser.py">/home/mcfletch/pylive/simpleparse/parser.py</a></font></td></tr></table>
    <p><tt>Real-world&nbsp;parsers&nbsp;using&nbsp;the&nbsp;SimpleParse&nbsp;EBNF</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#fffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
    
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="simpleparse.baseparser.html">simpleparse.baseparser</a><br>
</td><td width="25%" valign=top><a href="simpleparse.common.html">simpleparse.common</a><br>
</td><td width="25%" valign=top><a href="simpleparse.simpleparsegrammar.html">simpleparse.simpleparsegrammar</a><br>
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
    
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="simpleparse.baseparser.html#BaseParser">BaseParser</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="simpleparse.parser.html#Parser">Parser</a>
</font></dt></dl>
</dd>
</dl>
 <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="Parser">class <strong>Parser</strong></a>(<a href="simpleparse.baseparser.html#BaseParser">BaseParser</a>)</font></td></tr>
    
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>EBNF-generated&nbsp;Parsers&nbsp;with&nbsp;results-handling<br>
&nbsp;<br>
The&nbsp;<a href="#Parser">Parser</a>&nbsp;is&nbsp;a&nbsp;two-stage&nbsp;object:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Passed&nbsp;an&nbsp;EBNF&nbsp;definition&nbsp;during&nbsp;initialisation,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;it&nbsp;compiles&nbsp;the&nbsp;definition&nbsp;into&nbsp;a&nbsp;tagging&nbsp;table<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(which&nbsp;in&nbsp;turn&nbsp;requires&nbsp;creating&nbsp;a&nbsp;tagging&nbsp;table<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;parsing&nbsp;the&nbsp;EBNF).<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;You&nbsp;then&nbsp;call&nbsp;the&nbsp;parser's&nbsp;parse&nbsp;method&nbsp;to<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;perform&nbsp;the&nbsp;actual&nbsp;parsing&nbsp;of&nbsp;your&nbsp;data,&nbsp;with&nbsp;the<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parser&nbsp;passing&nbsp;the&nbsp;results&nbsp;to&nbsp;your&nbsp;processor&nbsp;object<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;then&nbsp;back&nbsp;to&nbsp;you.<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="Parser-__init__"><strong>__init__</strong></a>(self, declaration, root<font color="#909090">='root'</font>, prebuilts<font color="#909090">=()</font>, definitionSources<font color="#909090">=[{'locale_day_abbrs': FirstOfGroup(
    children = [
        Literal(
...l(
            value = 'Fri',
        ),
    ],
), 'locale_day_abbrs_lc': FirstOfGroup(
    children = [
        Literal(
...l(
            value = 'fri',
        ),
    ],
), 'locale_day_abbrs_uc': FirstOfGroup(
    children = [
        Literal(
...l(
            value = 'FRI',
        ),
    ],
), 'locale_day_names': FirstOfGroup(
    children = [
        Literal(
...            value = 'Friday',
        ),
    ],
), 'locale_day_names_lc': FirstOfGroup(
    children = [
        Literal(
...            value = 'friday',
        ),
    ],
), 'locale_day_names_uc': FirstOfGroup(
    children = [
        Literal(
...            value = 'FRIDAY',
        ),
    ],
), 'locale_month_abbrs': FirstOfGroup(
    children = [
        Literal(
...eral(
            value = '',
        ),
    ],
), 'locale_month_abbrs_lc': FirstOfGroup(
    children = [
        Literal(
...eral(
            value = '',
        ),
    ],
), 'locale_month_abbrs_uc': FirstOfGroup(
    children = [
        Literal(
...eral(
            value = '',
        ),
    ],
), 'locale_month_names': FirstOfGroup(
    children = [
        Literal(
...eral(
            value = '',
        ),
    ],
), ...}, {'EOF': Prebuilt(
    value = ((None, 101, 1),),
), 'ascii_letter': Range(
    value = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
), 'ascii_letters': Range(
    repeating = 1,
    value = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
), 'ascii_lowercase': Range(
    repeating = 1,
    value = 'abcdefghijklmnopqrstuvwxyz',
), 'ascii_lowercasechar': Range(
    value = 'abcdefghijklmnopqrstuvwxyz',
), 'ascii_uppercase': Range(
    repeating = 1,
    value = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
), 'ascii_uppercasechar': Range(
    value = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
), 'digit': Range(
    value = '0123456789',
), 'digits': Range(
    repeating = 1,
    value = '0123456789',
), 'hexdigit': Range(
    value = '0123456789abcdefABCDEF',
), ...}, {'c_comment': LibraryElement(
    production = 'slashbang_comm...enerator.Generator instance at 0x2aaaad5dedd0&gt;,
), 'c_nest_comment': LibraryElement(
    production = 'slashbang_nest...enerator.Generator instance at 0x2aaaad5e7170&gt;,
), 'hash_comment': LibraryElement(
    production = 'hash_comment',...enerator.Generator instance at 0x2aaaad5d9128&gt;,
), 'semicolon_comment': LibraryElement(
    production = 'semicolon_comm...enerator.Generator instance at 0x2aaaad5d9128&gt;,
), 'slashbang_comment': LibraryElement(
    production = 'slashbang_comm...enerator.Generator instance at 0x2aaaad5dedd0&gt;,
), 'slashbang_nest_comment': LibraryElement(
    production = 'slashbang_nest...enerator.Generator instance at 0x2aaaad5e7170&gt;,
), 'slashslash_comment': LibraryElement(
    production = 'slashslash_com...enerator.Generator instance at 0x2aaaad5d9128&gt;,
)}, {'binary_number': LibraryElement(
    production = 'binary_number'...enerator.Generator instance at 0x2aaaad5f69e0&gt;,
), 'float': LibraryElement(
    production = 'float',
    ge...enerator.Generator instance at 0x2aaaad5f69e0&gt;,
), 'float_floatexp': LibraryElement(
    production = 'float_floatexp...enerator.Generator instance at 0x2aaaad5f69e0&gt;,
), 'hex': LibraryElement(
    production = 'hex',
    gene...enerator.Generator instance at 0x2aaaad5f69e0&gt;,
), 'imaginary_number': LibraryElement(
    production = 'imaginary_numb...enerator.Generator instance at 0x2aaaad5f69e0&gt;,
), 'int': LibraryElement(
    production = 'int',
    gene...enerator.Generator instance at 0x2aaaad5f69e0&gt;,
), 'int_unsigned': LibraryElement(
    production = 'int_unsigned',...enerator.Generator instance at 0x2aaaad5f69e0&gt;,
), 'number': LibraryElement(
    production = 'number',
    g...enerator.Generator instance at 0x2aaaad5f69e0&gt;,
), 'number_full': LibraryElement(
    production = 'number_full',
...enerator.Generator instance at 0x2aaaad5f69e0&gt;,
)}, {'ISO_date': LibraryElement(
    production = 'ISO_date',
   ...enerator.Generator instance at 0x2aaaad5dca28&gt;,
), 'ISO_date_time': LibraryElement(
    production = 'ISO_date_time'...enerator.Generator instance at 0x2aaaad5dca28&gt;,
), 'ISO_time': LibraryElement(
    production = 'ISO_time',
   ...enerator.Generator instance at 0x2aaaad5dca28&gt;,
)}, {'ISO_date_loose': LibraryElement(
    production = 'ISO_date_loose...enerator.Generator instance at 0x2aaaad6009e0&gt;,
), 'ISO_date_time_loose': LibraryElement(
    production = 'ISO_date_time_...enerator.Generator instance at 0x2aaaad6009e0&gt;,
), 'ISO_time_loose': LibraryElement(
    production = 'ISO_time_loose...enerator.Generator instance at 0x2aaaad6009e0&gt;,
)}, {'military_alphabet_char': FirstOfGroup(
    children = [
        Literal(
...(
            value = 'Zulu',
        ),
    ],
), 'military_alphabet_char_lower': FirstOfGroup(
    children = [
        Literal(
...(
            value = 'zulu',
        ),
    ],
)}, {'string': LibraryElement(
    production = 'string',
    g...enerator.Generator instance at 0x2aaaad608d88&gt;,
), 'string_double_quote': LibraryElement(
    production = 'str',
    gene...enerator.Generator instance at 0x2aaaad82b200&gt;,
), 'string_single_quote': LibraryElement(
    production = 'str',
    gene...enerator.Generator instance at 0x2aaaad602680&gt;,
), 'string_triple_double': LibraryElement(
    production = 'str',
    gene...enerator.Generator instance at 0x2aaaad5d95a8&gt;,
), 'string_triple_single': LibraryElement(
    production = 'str',
    gene...enerator.Generator instance at 0x2aaaad827710&gt;,
)}, {'civilian_timezone_name': FirstOfGroup(
    children = [
        Literal(
...
            value = 'ACSST',
        ),
    ],
), 'military_timezone_name': FirstOfGroup(
    children = [
        Literal(
...ral(
            value = 'A',
        ),
    ],
), 'timezone_name': FirstOfGroup(
    children = [
        Literal(
...ral(
            value = 'A',
        ),
    ],
)}]</font>)</dt><dd><tt>Initialise&nbsp;the&nbsp;parser,&nbsp;creating&nbsp;the&nbsp;tagging&nbsp;table&nbsp;for&nbsp;it<br>
&nbsp;<br>
declaration&nbsp;--&nbsp;simpleparse&nbsp;ebnf&nbsp;declaration&nbsp;of&nbsp;the&nbsp;language&nbsp;being&nbsp;parsed<br>
root&nbsp;--&nbsp;root&nbsp;production&nbsp;used&nbsp;for&nbsp;parsing&nbsp;if&nbsp;none&nbsp;explicitly&nbsp;specified<br>
prebuilts&nbsp;--&nbsp;sequence&nbsp;of&nbsp;(name,value)&nbsp;tuples&nbsp;with&nbsp;prebuilt&nbsp;tables,&nbsp;values<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;can&nbsp;be&nbsp;either&nbsp;objectgenerator&nbsp;EventToken&nbsp;sub-classes&nbsp;or&nbsp;TextTools<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tables<br>
definitionSources&nbsp;--&nbsp;dictionaries&nbsp;of&nbsp;common&nbsp;constructs&nbsp;for&nbsp;use<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;in&nbsp;building&nbsp;your&nbsp;grammar</tt></dd></dl>

<dl><dt><a name="Parser-buildTagger"><strong>buildTagger</strong></a>(self, production<font color="#909090">=None</font>, processor<font color="#909090">=None</font>)</dt><dd><tt>Get&nbsp;a&nbsp;particular&nbsp;parsing&nbsp;table&nbsp;for&nbsp;a&nbsp;particular&nbsp;production</tt></dd></dl>

<hr>
Methods inherited from <a href="simpleparse.baseparser.html#BaseParser">BaseParser</a>:<br>
<dl><dt><a name="Parser-buildProcessor"><strong>buildProcessor</strong></a>(self)</dt><dd><tt>Build&nbsp;default&nbsp;processor&nbsp;object&nbsp;for&nbsp;this&nbsp;parser&nbsp;class<br>
&nbsp;<br>
The&nbsp;default&nbsp;implementation&nbsp;returns&nbsp;None.&nbsp;&nbsp;The&nbsp;processor<br>
can&nbsp;either&nbsp;implement&nbsp;the&nbsp;"method&nbsp;source"&nbsp;API&nbsp;(just&nbsp;provides<br>
information&nbsp;about&nbsp;Callouts&nbsp;and&nbsp;the&nbsp;like),&nbsp;or&nbsp;the&nbsp;processor<br>
API&nbsp;and&nbsp;the&nbsp;method-source&nbsp;API.&nbsp;&nbsp;The&nbsp;processor&nbsp;API&nbsp;merely<br>
requires&nbsp;that&nbsp;the&nbsp;object&nbsp;be&nbsp;callable,&nbsp;and&nbsp;have&nbsp;the&nbsp;signature:<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;object(&nbsp;(success,&nbsp;children,&nbsp;nextPosition),&nbsp;buffer)<br>
&nbsp;<br>
(Note:&nbsp;your&nbsp;object&nbsp;can&nbsp;treat&nbsp;the&nbsp;first&nbsp;item&nbsp;as&nbsp;a&nbsp;single&nbsp;tuple<br>
if&nbsp;it&nbsp;likes).<br>
&nbsp;<br>
See:&nbsp;simpleparse.processor&nbsp;module&nbsp;for&nbsp;details.</tt></dd></dl>

<dl><dt><a name="Parser-parse"><strong>parse</strong></a>(self, data, production<font color="#909090">=None</font>, processor<font color="#909090">=None</font>, start<font color="#909090">=0</font>, stop<font color="#909090">=None</font>)</dt><dd><tt>Parse&nbsp;data&nbsp;with&nbsp;production&nbsp;"production"&nbsp;of&nbsp;this&nbsp;parser<br>
&nbsp;<br>
data&nbsp;--&nbsp;data&nbsp;to&nbsp;be&nbsp;parsed,&nbsp;a&nbsp;Python&nbsp;string,&nbsp;for&nbsp;now<br>
production&nbsp;--&nbsp;optional&nbsp;string&nbsp;specifying&nbsp;a&nbsp;non-default&nbsp;production&nbsp;to&nbsp;use<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;parsing&nbsp;data<br>
processor&nbsp;--&nbsp;optional&nbsp;pointer&nbsp;to&nbsp;a&nbsp;Processor&nbsp;or&nbsp;MethodSource&nbsp;object&nbsp;for<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;use&nbsp;in&nbsp;determining&nbsp;reporting&nbsp;format&nbsp;and/or&nbsp;post-processing&nbsp;the&nbsp;results<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;of&nbsp;the&nbsp;parsing&nbsp;pass.&nbsp;&nbsp;Can&nbsp;be&nbsp;None&nbsp;if&nbsp;neither&nbsp;is&nbsp;desired&nbsp;(default)<br>
start&nbsp;--&nbsp;starting&nbsp;index&nbsp;for&nbsp;the&nbsp;parsing,&nbsp;default&nbsp;0<br>
stop&nbsp;--&nbsp;stoping&nbsp;index&nbsp;for&nbsp;the&nbsp;parsing,&nbsp;default&nbsp;len(data)</tt></dd></dl>

<dl><dt><a name="Parser-resetBeforeParse"><strong>resetBeforeParse</strong></a>(self)</dt><dd><tt>Called&nbsp;just&nbsp;before&nbsp;the&nbsp;parser's&nbsp;parse&nbsp;method&nbsp;starts&nbsp;working,<br>
&nbsp;<br>
Allows&nbsp;you&nbsp;to&nbsp;set&nbsp;up&nbsp;special-purpose&nbsp;structures,&nbsp;such&nbsp;as&nbsp;stacks<br>
or&nbsp;local&nbsp;storage&nbsp;values.&nbsp;&nbsp;There&nbsp;is&nbsp;no&nbsp;base&nbsp;implementation.&nbsp;&nbsp;The<br>
base&nbsp;implementation&nbsp;does&nbsp;nothing.</tt></dd></dl>

</td></tr></table></td></tr></table>
</body></html>